package net.hn.hnms.biz.emgcy.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import net.hn.hnms.biz.emgcy.domain.RescueHeadquartersPo;
import net.hn.hnms.biz.emgcy.domain.dto.RescueHeadquartersDto;
import net.hn.hnms.biz.emgcy.domain.vo.RescueHeadquartersVo;
import net.hn.hnms.biz.emgcy.service.RescueHeadquartersService;
import net.hn.hnms.sys.common.core.domain.R;
import net.hn.hnms.sys.common.core.domain.ResponsePage;
import net.hn.hnms.sys.common.mybatis.core.page.PageQuery;
import net.hn.hnms.sys.common.satoken.config.AutoSetMineCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author: baijiajun
 * @Date: 2022/9/13
 */
@Api(value = "救援指挥部模块", tags = {"救援指挥部"})
@RestController
@RequestMapping("rescueHeadquarters")
public class RescueHeadquartersController {
    @Autowired
    private RescueHeadquartersService rescueHeadquartersService;

    @ApiOperation("救援指挥部列表")
    @GetMapping("pageList")
    @AutoSetMineCode
    public R<ResponsePage<RescueHeadquartersVo>> pageList(PageQuery pageQuery, RescueHeadquartersDto rescueHeadquartersDto) {
        ResponsePage<RescueHeadquartersVo> list=rescueHeadquartersService.pageList(pageQuery,rescueHeadquartersDto);
        return R.ok(list);
    }

    @ApiOperation("救援指挥展示")
    @GetMapping("/list")
    public R list(){
        return R.ok(rescueHeadquartersService.list());
    }

    @ApiOperation("救援指挥部添加")
    @PostMapping("/add")
    public R add(@RequestBody RescueHeadquartersPo rescueHeadquartersPo){
        Boolean flag = rescueHeadquartersService.add(rescueHeadquartersPo);
        if(flag){
            return R.ok("新增成功");
        }
        return R.fail("新增失败");
    }

    @ApiOperation("救援指挥部修改")
    @PutMapping("/update")
    public R update(@RequestBody RescueHeadquartersPo rescueHeadquartersPo){
        Boolean flag = rescueHeadquartersService.update(rescueHeadquartersPo);
        if(flag){
            return R.ok("修改成功");
        }
        return R.fail("修改失败");
    }
    @ApiOperation("救援指挥部删除")
    @DeleteMapping("/delete/{id}")
    public R delete(@PathVariable Long id){
        Boolean flag = rescueHeadquartersService.delete(id);
        if(flag){
            return R.ok("删除成功");
        }
        return R.fail("删除失败");
    }
}
